<?php
namespace app\common\only\jy;

class OrderRefund extends Base {
	protected $prefix = 'jy\\OrderRefund';

	//获取未完成退款单数量
	public function hasRefund($oid) {
		$model = $this->getModel();
		return $this->get('has_refund_' . $oid, function($model, $oid) {
			$statusEnum = loadEnum('OrderRefundStatus');
			$statusArr = $statusEnum->over();
			return $model->where(['oid' => $oid])->whereNotIn('status', $statusArr)->count();
		}, [$model, $oid]);
	}

	//通过订单id查询未完成退款单
	public function order2refund($oid) {
		$model = $this->getModel();
		return $this->get('has_refund_' . $oid, function($model, $oid) {
			$statusEnum = loadEnum('OrderRefundStatus');
			$statusArr = $statusEnum->over();
			return $model->where(['oid' => $oid])->whereNotIn('status', $statusArr)->select();
		}, [$model, $oid]);
	}
}